<template>
	<view :style="{display: visible ? 'block' : 'none' }" class="common-car">
	
		<view class="empty-shop-car" v-if="isEmpty">
		</view>
		<view class="shop-car">
			<view class="store-box" v-for="(product,index) in prodectslist" :key="index">
				<view class="goodsInfo">
					<view class="goodsInfo-right">
						<image :src="product.commodityList.icon" class="goods-image" mode=""></image>
						<view class="goodsInfo-box">
							<text style="margin-left: 20px;"  class="goods-name"
								@click="prodctDetail(product)">{{product.commodityList.commodityName}}</text>
							<text v-if="product.commodityNorms!=null" class="spe">规格：
								<text style="margin-right: 10px;"
									v-for="(item,index) in product.commodityNorms.skuNameArr">{{item}}
								</text>
							</text>
							<view class="goods-box">
								<text v-if="product.commodityNorms!=null"
									class="goods-price">¥{{product.commodityNorms.sellingPrice}}</text>
								<view class="goods-num-box">
									<view class="statistics-right" v-if="isCut" @tap="accounts">
										<view class="btn">
											<text>推荐</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getRecommendList
	} from "@/server/headhome.js"

	export default {
		props: {
			visible: Boolean
		},
		data() {
			return {
				isEmpty: false,
				prodectslist: [],
				total: 0,
				isCut: true,
				selectProductsList: [],
				param: {
					page: 1,
					limit: 100,
					recommendMember: 1,
					recommendStatus: 0
				}
			}
		},
		onLoad() {
		
		},
		created() {
		
			uni.showLoading({
				title: '加载中'
			});
			getRecommendList(this.param).then(data => {
				uni.hideLoading()
				this.prodectslist=data.list
		
			}).catch(err => {
						uni.hideLoading()
			});
		},
		methods: {
	
			accounts() {
				this.prodectslist.forEach((item, index) => {
					if (item.checked == 2) {
						this.selectProductsList.push(item)
					}
				})
			
				uni.navigateTo({
					url: '/pages/order/createOrder?selectProductsList=' + encodeURIComponent(JSON.stringify(
						this.selectProductsList))
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	.common-car {
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #F5F5F5;
	}

	.empty-shop-car {
		width: 750rpx;
		min-height: 680rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		text {
			margin-top: 40rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #666666;
		}
	}

	.shop-car {
		margin-top: 5rpx;
		width: 750rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		.store-box {
			width: 750rpx;
			margin-bottom: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			background-color: #FFFFFF;

			.goodsInfo {
				display: flex;
				flex-direction: row;
				align-items: center;
				border-bottom: 2rpx solid #EDEDED;

				&:nth-last-child(1) {
					border: none;
				}

				.goodsInfo-right {
					width: 700rpx;
					height: 246rpx;
					margin-left: 30rpx;
					display: flex;
					flex-direction: row;
					align-items: center;

					.goods-image {
						width: 180rpx;
						height: 180rpx;
					}

					.goodsInfo-box {
						width: 430rpx;
						margin-left: 24rpx;
						display: flex;
						flex-direction: column;
						align-items: center;

						.goods-name {
							width: 470rpx;
							font-size: 26rpx;
							font-weight: 400rpx;
							color: #313133;
						}

						.spe {
							width: 470rpx;
							margin-top: 10rpx;
							font-size: 24rpx;
							font-weight: 400;
							color: #919298;
						}

						.goods-box {
							width: 470rpx;
							margin-top: 10rpx;
							display: flex;
							flex-direction: row;
							align-items: center;
							justify-content: space-between;

							.goods-price {
								font-size: 32rpx;
								font-weight: 400;
								color: #313133;
							}

							.goods-num-box {
								width: 460rpx;
								height: 46rpx;
								display: flex;
								flex-direction: row;
								align-items: center;

								.goods-image {
									width: 46rpx;
									height: 44rpx;
									text-align: center;
									line-height: 44rpx;
									border: 1rpx solid #CFCFCF;
									font-size: 38rpx;
								}

								.statistics-right {
									width: 600rpx;
									display: flex;
									flex-direction: row;
									align-items: center;
									justify-content: flex-end;

									.btn {
										padding: 4px 50upx;
										border-radius: 100px;
										background: rgba(252, 2, 8, 1.0);
										text-align: center;

										font-size: 30rpx;
										font-weight: 400;
										color: #FFFFFF;
										margin-left: 40rpx;
									}

									text {
										font-size: 30rpx;
										font-weight: 500;
										color: #FFFFFF;
									}

									.text-color {
										color: rgba(242, 18, 18, 1);
									}
								}
							}
						}
					}
				}
			}
		}
	}
</style>
